# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=python2-cairo

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.0
pkgrel=1
pkgdesc="Python2 bindings for the cairo graphics library (mingw-w64)"
url="http://www.cairographics.org/pycairo"
arch=('any')
license=('LGPL' 'MPL')
depends=("${MINGW_PACKAGE_PREFIX}-python2" "${MINGW_PACKAGE_PREFIX}-python3" "${MINGW_PACKAGE_PREFIX}-cairo")
source=(http://cairographics.org/releases/py2cairo-${pkgver}.tar.bz2
    waflib.patch)
md5sums=('20337132c4ab06c1146ad384d55372c5'
         'dfbfb1d1901a311c2d2ca8e8ea1be592')

build() {
  cd "${srcdir}/py2cairo-${pkgver}"
  sed -i 's:bin/env python:bin/env python2:' waf
  /usr/bin/python2 ./waf --version
  pushd .waf-*
  patch -p0 -i ${srcdir}/waflib.patch
  rm -f waflib/*.pyc
  popd

  pushd ${MINGW_PREFIX} > /dev/null
  export PREFIX_DEPS=`pwd -W`
  popd > /dev/null

  export PYTHON=${MINGW_PREFIX}/bin/python2
  CFLAGS+=" -I${MINGW_PREFIX}/include/python2.7"
  /usr/bin/python2 ./waf --help
  /usr/bin/python2 ./waf configure --prefix=${MINGW_PREFIX}
  /usr/bin/python2 ./waf build
}

package() {
  cd "${srcdir}/py2cairo-${pkgver}"
  export PYTHON=${MINGW_PREFIX}/bin/python2
  /usr/bin/python2 ./waf install --destdir="${pkgdir}"
  
  rm -rf ${pkgdir}${MINGW_PREFIX}/lib
  mv ${pkgdir}${MINGW_PREFIX}/bin ${pkgdir}${MINGW_PREFIX}/lib
}
